import service from '@/utils/axios';
import { IResponseType, PageVO } from '@/api/common';
import {
    TopicAddRO,
    TopicEditRO,
    TopicPageRO,
    TopicVO
} from '@/api/content/topic/topic';

export const getTopicInfo = (id: string) => {
    return service<IResponseType<TopicVO>>({
        url: '/content/topic/get/' + id,
        method: 'post'
    });
};

export const getTopicPage = (pageRO: TopicPageRO) => {
    return service<IResponseType<PageVO<TopicVO>>>({
        url: '/content/topic/page',
        method: 'post',
        data: pageRO
    });
};

export const getTopicAll = async () => {
    return  service<IResponseType<PageVO<TopicVO>>>({
        url: '/content/topic/page',
        method: 'post',
        data: {
            current: 1,
            size: 1000
        }
    });
};

export const addTopic = (data: TopicAddRO) => {
    return service<IResponseType<void>>({
        url: '/content/topic/add',
        method: 'post',
        data
    });
};

export const editTopic = (data: TopicEditRO) => {
    return service<IResponseType<void>>({
        url: '/content/topic/edit',
        method: 'post',
        data
    });
};

export const remove = (ids: string) => {
    return service<IResponseType<void>>({
        url: '/content/topic/remove/' + ids,
        method: 'post'
    });
};